import uuid

from django.db import models
from django.urls import reverse
from User.models import *


# Create your models here.


class Courses(models.Model):
    CourseName = models.CharField(max_length=128, verbose_name='课程名')
    StudentID = models.ForeignKey(UserInfo, verbose_name='学号', on_delete=models.CASCADE)
    StartTime = models.CharField(max_length=128, verbose_name='开始时间')
    Teacher = models.CharField(max_length=128, verbose_name='教师')
    Class = models.CharField(max_length=128, verbose_name='班级')
    ClassWeek = models.CharField(max_length=128, verbose_name='教学周')
    EndTime = models.CharField(max_length=128, verbose_name='结束时间')
    Week = models.CharField(max_length=128, verbose_name='星期')
    room = models.CharField(max_length=128, verbose_name='教室')
    Date = models.DateTimeField(verbose_name='更新日期', auto_now=True)

    class Meta:
        verbose_name = "课程"
        verbose_name_plural = verbose_name + "管理"
        unique_together = ("StudentID", "CourseName", "StartTime", "Week", "ClassWeek")

    def __str__(self):
        return self.CourseName


class Events(models.Model):
    EventsID = models.UUIDField(max_length=6, verbose_name='日程ID', unique=True, db_index=True, primary_key=True,
                                default=uuid.uuid1, editable=False)
    EventsName = models.CharField(max_length=128, verbose_name='日程名', unique=True, db_index=True)
    StudentID = models.ForeignKey(UserInfo, verbose_name='学号', db_index=True, on_delete=models.CASCADE)
    StartTime = models.CharField(max_length=128, verbose_name='开始时间')
    EndTime = models.CharField(max_length=128, verbose_name='结束时间')
    Week = models.CharField(max_length=128, verbose_name='星期')
    Date = models.DateTimeField(verbose_name='更新日期', auto_now=True)

    class Meta:
        verbose_name = "日程"
        verbose_name_plural = verbose_name + "管理"

    def __str__(self):
        return self.EventsName


class Meetings(models.Model):
    MeetingID = models.UUIDField(max_length=128, verbose_name='会议ID', unique=True, db_index=True, primary_key=True,
                                 default=uuid.uuid1, editable=False)
    MeetingName = models.CharField(max_length=128, verbose_name='会议名', unique=True, db_index=True)
    StudentID = models.ForeignKey(UserInfo, verbose_name='学号', db_index=True, on_delete=models.CASCADE)
    StartTime = models.CharField(max_length=128, verbose_name='开始时间')
    EndTime = models.CharField(max_length=128, verbose_name='结束时间')
    Week = models.CharField(max_length=128, verbose_name='星期')
    Date = models.DateTimeField(verbose_name='更新日期', auto_now=True)
    class Meta:
        verbose_name = "会议"
        verbose_name_plural = verbose_name + "管理"

    def __str__(self):
        return self.MeetingName
